package com.ycx.ycxmybatismanagement.mapper;

import com.ycx.ycxmybatismanagement.pojo.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface DeptMapper {
    //查询
//    @Results({
//            @Result(column = "create_time",property = "createTime"),
//            @Result(column = "update_time",property = "updateTime"),
//    })
//    @Select("select * from dept")
    List<Dept> deptList();

    /**
     * 删除
     * @param id
     */
//    @Delete("delete from dept where id = #{id}")
    void deleteDept(int id);

    /**
     * 添加
     * @param dept
     */
    @Results({
            @Result(column = "create_time" ,property = "createTime"),
            @Result(column = "update_time" ,property = "updateTime")
    })
    @Insert("insert into dept (name,create_time,update_time) values (#{name},#{createTime},#{updateTime})")
    void insertDept(Dept dept);
    //回显
    @Select("select * from dept where id = #{id}")
    Dept selectDeptById(Integer id);

    //修改
//    @Update("update dept set name =#{name},create_time =#{createTime},update_time =#{updateTime} where id =#{id}")
    void updateDept(Dept dept);
}
